package interfaz2;

import java.security.Security;

import org.bouncycastle.jce.provider.BouncyCastleProvider;

import p2pmodule.P2PModule;
import dustconf.DustConf;
import dustdispatcher.DustDispatcher;

/**
 * Dust entry point! Here comes the whole magic.
 * 
 * @author ole
 */
public class Main {
	private static final String DUST_CONF_FILE = "conf/dust.conf";
	
	/**
	 * Main function. The entry point.
	 */
	public static void main(String[] args) throws Exception {
		DustInterface dust_iface;
		
		// Add Bouncy Castle as a new provider of security.
		Security.addProvider(new BouncyCastleProvider());
		
		// Create the configuration (it is used internally).
		new DustConf(DUST_CONF_FILE);
		
		// Initializes the P2PModule (it is used internally).
		new P2PModule();
		
		// Initializes the DustDispatcher module (it is used internally).
		new DustDispatcher();
		
		// Create the interface.
		dust_iface = new DustInterface();
		
		// RUN THE MAGIC!.
		dust_iface.runIface();
		
		// From here the code is only reached if Dust has to shut down.
		P2PModule.shutdown();
	}
}
